pandas remove whitespace

54

df.columns = df.columns.str.replace(' ', '')
df.columns = df.columns.str.strip()
df.columns = df.columns.str.rstrip()
df.columns = df.columns.str.lstrip()
'     hello world!    '.strip()
'hello world!'


'     hello world!    '.lstrip()
'hello world!    '

'     hello world!    '.rstrip()
'    hello world!'
str.strip() method

Comments

Submit
0 Comments